// ActionScript file
import datas.LibraryItem;
import datas.LibraryItemType;

import flash.events.Event;
import flash.filesystem.File;
import flash.net.FileFilter;

import mx.collections.ArrayList;
import mx.events.FlexEvent;

[Bindable]
public var _cells:ArrayList = new ArrayList();

public function JWebToonImplement(): void
{
	// [ 파일 선택 버튼 ]
	this.btnFile.addEventListener( FlexEvent.BUTTON_DOWN, onDownFileButton );
}

private function onDownFileButton( e: FlexEvent ): void
{
	
	var _file: File = new File();
	_file.addEventListener( Event.SELECT, onSelectFile );
	_file.addEventListener( Event.COMPLETE, onSelectComplete );
	_file.browse( [ new FileFilter( "Image", "*.png" )] );
}

private function onSelectFile( e: Event ): void
{
	var _file: File = e.target as File;
	_file.load();
	
	var _cell: LibraryItem = new LibraryItem( _file );
	_cells.addItem( _cell );
	
}

private function onSelectComplete( e: Event ): void
{
	var _file: File = e.target as File;
	
	//var _loader: Loader = new Loader();
	//_loader.loadBytes( _file.data );
	//this.addChild( _loader );
	
	// FIlePathManager.saveToImageResourcePath( _file );
}

private function onStoryBoradChange(): void
{
	trace( "storyBorad change" );
}